<template>
  <el-container>
    <aside-layout></aside-layout>
    <el-main>
      <div class="page-container">
        <h1><i class="el-icon-s-cooperation"></i> 套餐选择</h1>
        <el-row :gutter="20">
          <el-col :span="8" v-for="(mealPackage, index) in mealPackages" :key="index">
            <el-card :body-style="{ padding: '0px' }" class="meal-card" @click="selectPackage(mealPackage)">
              <img :src="mealPackage.image" :alt="mealPackage.name" class="meal-image" />
              <div style="padding: 14px;">
                <h3>{{ mealPackage.name }}</h3>
                <p>{{ mealPackage.description }}</p>
                <p class="price">价格: {{ mealPackage.price }}</p>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <el-dialog :visible.sync="dialogVisible" title="套餐详情" width="50%">
          <img :src="selectedPackage.image" :alt="selectedPackage.name" class="dialog-image" />
          <h2>{{ selectedPackage.name }}</h2>
          <p>{{ selectedPackage.description }}</p>
          <p class="price">价格: {{ selectedPackage.price }}</p>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">关闭</el-button>
            <el-button type="primary" @click="orderPackage">下单</el-button>
          </span>
        </el-dialog>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import AsideLayout from '@/layout/asideLayout.vue';

export default {
  name: 'MealPackages',
  components: {
    AsideLayout
  },
  data() {
    return {
      mealPackages: [
        { name: '套餐A', description: '包含主菜、配菜和饮料', price: '¥50', image: 'path/to/imageA.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        { name: '套餐B', description: '包含主菜和甜点', price: '¥60', image: 'path/to/imageB.jpg' },
        // 更多套餐可以在这里添加
      ],
      dialogVisible: false,
      selectedPackage: {}
    };
  },
  methods: {
    selectPackage(mealPackage) {
      this.selectedPackage = mealPackage;
      this.dialogVisible = true;
    },
    orderPackage() {
      console.log('下单:', this.selectedPackage);
      this.dialogVisible = false;
    }
  }
};
</script>

<style scoped>
.page-container {
  padding: 20px;
}

.meal-card {
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.meal-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.meal-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.price {
  color: #f56c6c;
  font-weight: bold;
}

.dialog-image {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
}
</style>